package edu.towson.cis.cosc490.jday3.lab3;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class NewItemActivity extends Activity implements OnClickListener {
	
	public Button m_addButton;
	public EditText m_editText;
	public RadioGroup m_radioGroup;
	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_create);
        
        initLayout();

        m_addButton.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    public void initLayout(){
    	m_addButton = (Button) this.findViewById(R.id.button1);
    	m_editText = (EditText) this.findViewById(R.id.editText1);
    	m_radioGroup = (RadioGroup) this.findViewById(R.id.radioGroup1);
    }

	public void onClick(View v) {
		String str = m_editText.getText().toString();
		int priority = m_radioGroup.indexOfChild(findViewById(m_radioGroup.getCheckedRadioButtonId()));
		Intent i = new Intent();
		i.putExtra("text", str);
		i.putExtra("priority", priority);
		setResult(RESULT_OK,i);
		finish();
	}
}
